package ticket8088.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import ticket8088.entity.po.Ticket;
import ticket8088.entity.vo.TicketVO;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ttxxi
 * @since 2022-05-31
 */
public interface TicketMapper extends BaseMapper<Ticket> {

    @Select("SELECT " +
            "t.id, " +
            "t.create_time, " +
            "t.schedule_id, " +
            "s.`year`, " +
            "s.`month`, " +
            "s.date, " +
            "s.`hour`, " +
            "s.`minute`, " +
            "d.destination " +
            "FROM " +
            "ticket AS t " +
            "LEFT JOIN `schedule` AS s ON s.id = t.schedule_id " +
            "LEFT JOIN destination AS d ON s.destination_id = d.id " +
            "WHERE t.user_id = #{userId}"
    )
    List<TicketVO> selectTicketVOByUserId(@Param("userId") Long userId);

}
